﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;

namespace vJine.Lua.GUI.UI {
    public class AdornorHelper {
        public class MoveAdornor : Adorner {
            public MoveAdornor(UIElement adornedElement)
                : base(adornedElement) {

            }
            protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) {
                Rect adornedElementRect = new Rect(this.AdornedElement.RenderSize);

                // Some arbitrary drawing implements.
                SolidColorBrush renderBrush = new SolidColorBrush(Colors.Green);
                renderBrush.Opacity = 0.2;
                Pen renderPen = new Pen(new SolidColorBrush(Colors.Navy), 1.5);
                double renderRadius = 5.0;

                // Draw a circle at each corner.
                drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopLeft, renderRadius, renderRadius);
                drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopRight, renderRadius, renderRadius);
                drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomLeft, renderRadius, renderRadius);
                drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomRight, renderRadius, renderRadius);

                this.MouseLeftButtonDown += MoveAdornor_MouseLeftButtonDown;
            }

            void MoveAdornor_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) {
                Point p = e.GetPosition(sender as IInputElement);
                Debug.WriteLine("Adorner:{0},{1}",p.X, p.Y);
                e.Handled = true;
            }
        }
    }
}
